/**
 * Created by Administrator on 2018-08-10.
 * 保障进程监控
 */


define(function (require,exports,module) {
    var sTpl = require("./secProcessControl.html");
    require("./secProcessControl.css");
    require("../../lib/fullcalendar/moment.min.js");
    var VueComponent = Vue.extend({
        template: sTpl,
        data:function () {
            var date = moment().format("YYYY-MM-DD");
            return {
                today:date,
                secpcInData:[],
                secpcOutInData:[],
                flightInfo:{},
                planes:[],
                form: {
                    flightInfo:{flightInfoId:""},
                },
            }
        },
        methods: {
/*
    {row, column, rowIndex, columnIndex}
*/
            cellStyle: function (a) {
                if(a.columnIndex == 7){
                    return 'border';

                }
                if(a.columnIndex == 8 && a.row.boardingGateDone=='登机口到位'){
                   /*保障成功*/
                    if(a.row.isDelay!='延误'&&a.row.isRemotegatePosition!="远机位"&&a.row.isChangeMessage!='更换信息'){
                        return 'success1';
                    }
                    /*延误*/
                    if(a.row.isDelay=='延误'&&a.row.isRemotegatePosition!="远机位"&&a.row.isChangeMessage!='更换信息'){
                        return 'isDelay1';
                    }
                    /*延误+远机位*/
                    if(a.row.isDelay=='延误'&&a.row.isRemotegatePosition=="远机位"&&a.row.isChangeMessage!='更换信息'){
                        return 'isDelayAndRp';
                    }
                    /*延误+更换信息*/
                    if(a.row.isDelay=='延误'&&a.row.isRemotegatePosition!="远机位"&&a.row.isChangeMessage=='更换信息'){
                        return 'isDelayAndCm';
                    }
                    /*延误+更换信息+远机位*/
                    if(a.row.isDelay=='延误'&&a.row.isRemotegatePosition=="远机位"&&a.row.isChangeMessage=='更换信息'){
                        return 'isDelayAndRpAndCm';
                    }
                    /*远机位*/
                    if(a.row.isDelay!='延误'&&a.row.isRemotegatePosition=="远机位"&&a.row.isChangeMessage!='更换信息'){
                        return 'isRp';
                    }
                    /*远机位+更换信息*/
                    if(a.row.isDelay!='延误'&&a.row.isRemotegatePosition=="远机位"&&a.row.isChangeMessage=='更换信息'){
                        return 'isRpAndCm';
                    }
                    /*更换信息*/
                    if(a.row.isDelay!='延误'&&a.row.isRemotegatePosition!="远机位"&&a.row.isChangeMessage=='更换信息'){
                        return 'isCm';
                    }
                }
                /*第九行机坪到位*/
                if(a.columnIndex == 9&&a.row.apronDone=='机坪到位'){
                    /*保障成功*/
                    if(a.row.isDelay!='延误'&&a.row.isRemotegatePosition!="远机位"&&a.row.isChangeMessage!='更换信息'){
                        return 'success';
                    }
                    /*延误*/
                    /*延误+远机位*/
                    /*延误+更换信息*/
                    /*延误+远机位+更换信息*/
                    if(a.row.isDelay=='延误'){
                        return 'isDelay';
                    }
                    /*远机位*/
                    /*远机位+更换信息*/
                    if(a.row.isDelay!='延误'&&a.row.isRemotegatePosition=="远机位"){
                        return 'isRemotegatePosition';
                    }
                    /*更换信息*/
                    if(a.row.isDelay!='延误'&&a.row.isRemotegatePosition!="远机位"&&a.row.isChangeMessage=='更换信息'){
                        return 'isChangeMessage';
                    }
                }
                /*第十行航班落地/登机开始*/
                if(a.columnIndex ==10 &&(a.row.flightLand=='航班落地'|| a.row.boardingBegin=='登机开始')){
                    /*保障成功*/
                    if(a.row.isDelay!='延误'&&a.row.isRemotegatePosition!="远机位"&&a.row.isChangeMessage!='更换信息'){
                        return 'success';
                    }
                    /*延误*/
                    /*延误+远机位*/
                    /*延误+更换信息*/
                    /*延误+远机位+更换信息*/
                    if(a.row.isDelay=='延误'){
                        return 'isDelay';
                    }
                    /*远机位*/
                    /*远机位+更换信息*/
                    if(a.row.isDelay!='延误'&&a.row.isRemotegatePosition=="远机位"){
                        return 'isRemotegatePosition';
                    }
                    /*更换信息*/
                    if(a.row.isDelay!='延误'&&a.row.isRemotegatePosition!="远机位"&&a.row.isChangeMessage=='更换信息'){
                        return 'isChangeMessage';
                    }
                }
                /*第十一行下客结束/关闭舱门*/
                if(a.columnIndex ==11&&(a.row.dropOffEnd=='下客结束'||a.row.closeCabinDoor=='关闭舱门')){
                    /*保障成功*/
                    if(a.row.isDelay!='延误'&&a.row.isRemotegatePosition!="远机位"&&a.row.isChangeMessage!='更换信息'){
                        return 'success';
                    }
                    /*延误*/
                    /*延误+远机位*/
                    /*延误+更换信息*/
                    /*延误+远机位+更换信息*/
                    if(a.row.isDelay=='延误'){
                        return 'isDelay';
                    }
                    /*远机位*/
                    /*远机位+更换信息*/
                    if(a.row.isDelay!='延误'&&a.row.isRemotegatePosition=="远机位"){
                        return 'isRemotegatePosition';
                    }
                    /*更换信息*/
                    if(a.row.isDelay!='延误'&&a.row.isRemotegatePosition!="远机位"&&a.row.isChangeMessage=='更换信息'){
                        return 'isChangeMessage';
                    }
                }
                /*第十二行等登机口释放*/
                if(a.columnIndex ==12&&a.row.boardingGateFree=='登机口释放'){
                    /*保障成功*/
                    if(a.row.isDelay!='延误'&&a.row.isRemotegatePosition!="远机位"&&a.row.isChangeMessage!='更换信息'){
                        return 'success';
                    }
                    /*延误*/
                    /*延误+远机位*/
                    /*延误+更换信息*/
                    /*延误+远机位+更换信息*/
                    if(a.row.isDelay=='延误'){
                        return 'isDelay';
                    }
                    /*远机位*/
                    /*远机位+更换信息*/
                    if(a.row.isDelay!='延误'&&a.row.isRemotegatePosition=="远机位"){
                        return 'isRemotegatePosition';
                    }
                    /*更换信息*/
                    if(a.row.isDelay!='延误'&&a.row.isRemotegatePosition!="远机位"&&a.row.isChangeMessage=='更换信息'){
                        return 'isChangeMessage';
                    }
                }
                /*第十三行机坪人员释放*/
                if(a.columnIndex ==13&& a.row.apronCrewFree=='机坪人员释放'){
                    /*保障成功*/
                    if(a.row.isDelay!='延误'&&a.row.isRemotegatePosition!="远机位"&&a.row.isChangeMessage!='更换信息'){
                        return 'success';
                    }
                    /*延误*/
                    /*延误+远机位*/
                    /*延误+更换信息*/
                    /*延误+远机位+更换信息*/
                    if(a.row.isDelay=='延误'){
                        return 'isDelay';
                    }
                    /*远机位*/
                    /*远机位+更换信息*/
                    if(a.row.isDelay!='延误'&&a.row.isRemotegatePosition=="远机位"){
                        return 'isRemotegatePosition';
                    }
                    /*更换信息*/
                    if(a.row.isDelay!='延误'&&a.row.isRemotegatePosition!="远机位"&&a.row.isChangeMessage=='更换信息'){
                        return 'isChangeMessage';
                    }
                }






            },

            findFlightPlan:function () {
                var $this = this;
                axios.get(basepath+"/api/flightPlane/findNextDayPlan?order=estimatedTime&importOrExport=进港&flightInfoId="+this.form.flightInfo.flightInfoId+
                    "&estimatedTime=2018-08-18"
                ).then(function (response) {
                    $this.secpcInData=response.data;
                });

                axios.get(basepath+"/api/flightPlane/findNextDayPlan?order=estimatedTime&importOrExport=出港&flightInfoId="+this.form.flightInfo.flightInfoId+
                    "&estimatedTime=2018-08-18"
                ).then(function (response) {
                    $this.secpcOutInData=response.data;
                });

            }
        },
        watch:{
        },
        computed:{

        },
        created:function () {
            this.findFlightPlan();
            var $this = this;
            axios.get(basepath+"/api/flightInfo/queryFlightInfo?filter=").then(function (response) {
                $this.planes=response.data;
                $this.planesMap={};
                $this.planes.forEach(function(plane){
                    plane.value= plane.flightNum;
                    $this.planesMap[plane.flightNum] = plane;
                })
            })

        },
        activated:function () {
            messages.$emit('change','保障进程监控');
        }
    })
    module.exports=VueComponent;
    module.exports.reDefine=function (val) {
        module.exports.type=val;
        return module.exports;
    }

})


